package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.GregorianCalendar;

/**
 * Created by icarter on 14-06-02.
 */
public class BookList {
    ArrayList<Book> bookList;

    public BookList() {
        bookList = new ArrayList<Book>();
        for (int i = 0; i < 5; i++) {
            bookList.add(new Book("book" + i, "author" + i, new GregorianCalendar()) {
            });
        }
    }

    //Added for testing purposes
    public BookList(ArrayList<Book> list) {
        bookList = list;
    }

    public Book findBook(int id) {
        Book book = bookList.get(id);
        return book;
    }

    public void displayBooks() {
        System.out.println("id\t title\t author\t published in");
        for (int i = 0; i < bookList.size();  i++) {
            Book book = bookList.get(i);
            if (book.available) {
                System.out.println(i +
                                    "\t " + book.title +
                                    "\t " + book.author +
                                    "\t " + book.publishYear);
            }
        }
    }
}
